home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.2 Applications 1996 May / SGI IRIX 6.2 Applications 1996 May.iso / dist / impr_dev.idb / usr / impressario / src / examples / libspool / printers.c.z / printers.c
Encoding:
C/C++ Source or Header  |  1996-05-07  |  3.4 KB  |  116 lines

  1. /**************************************************************************
  2.  *                                      *
  3.  *           Copyright (c)    1991 Silicon Graphics, Inc.          *
  4.  *            All Rights Reserved                    *
  5.  *                                      *
  6.  *       THIS    IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI          *
  7.  *                                      *
  8.  * The copyright notice above does not evidence any actual of intended      *
  9.  * publication of such source code, and is an unpublished work by Silicon *
  10.  * Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
  11.  * the property of Silicon Graphics, Inc. Any use, duplication or      *
  12.  * disclosure not specifically authorized by Silicon Graphics is strictly *
  13.  * prohibited.                                  *
  14.  *                                      *
  15.  * RESTRICTED RIGHTS LEGEND:                          *
  16.  *                                      *
  17.  * Use, duplication or disclosure by the Government is subject to      *
  18.  * restrictions as set forth in subdivision (c)(1)(ii) of the Rights in      *
  19.  * Technical Data and Computer Software clause at DFARS 52.227-7013,      *
  20.  * and/or in similar or successor clauses in the FAR, DOD or NASA FAR      *
  21.  * Supplement. Unpublished - rights reserved under the Copyright Laws of  *
  22.  * the United States. Contractor is SILICON GRAPHICS, INC., 2011 N.      *
  23.  * Shoreline Blvd., Mountain View, CA 94039-7311              *
  24.  **************************************************************************
  25.  *
  26.  * File: printers.c
  27.  *
  28.  * Description: Prints a list of the printers available under each of the
  29.  *    available spooling systems.
  30.  *
  31.  **************************************************************************/
  32.  
  33.  
  34. #ident "$Revision: 1.1 $"
  35.  
  36.  
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include "spool.h"
  40.  
  41.  
  42. void print_info(SLPrinterStruct*);
  43.  
  44.  
  45. main()
  46. {
  47.     int i, num_printers;
  48.     SLPrinterStruct *printers;    /* Refer to SLGetPrinterList(3) man page */
  49.     char *pname;
  50.  
  51.     /*
  52.      * Get BSD known printers and default
  53.      */
  54.     if (SLSetSpooler(SL_SPOOLER_BSD) >= 0) {
  55.     if (SLGetPrinterList(&printers, &num_printers) < 0) {
  56.         SLPerror("printers");
  57.         exit(1);
  58.     }
  59.     (void)printf("BSD Printers (%d):\n", num_printers);
  60.     for (i = 0; i < num_printers; i++)
  61.         print_info(&printers[i]);
  62.     (void)printf("\nBSD Default Printer:\n");
  63.     if (SLGetDefPrinterName(&pname) < 0 && pname) {
  64.         SLPerror("printers");
  65.         exit(1);
  66.     }
  67.     if (pname)
  68.         (void)printf("\t%s\n", pname);
  69.     else
  70.         (void)printf("\tNone\n");
  71.     }
  72.  
  73.     (void)printf("\n");
  74.  
  75.     /*
  76.      * Get Sys V known printers
  77.      */
  78.     if (SLSetSpooler(SL_SPOOLER_SYSV) >= 0) {
  79.     if (SLGetPrinterList(&printers, &num_printers) < 0) {
  80.         SLPerror("printers");
  81.         exit(1);
  82.     }
  83.     (void)printf("System V Printers (%d):\n", num_printers);
  84.     for (i = 0; i < num_printers; i++)
  85.         print_info(&printers[i]);
  86.     (void)printf("\nSystem V Default Printer:\n");
  87.     if (SLGetDefPrinterName(&pname) < 0 && pname) {
  88.         SLPerror("printers");
  89.         exit(1);
  90.     }
  91.     if (pname)
  92.         (void)printf("\t%s\n", pname);
  93.     else
  94.         (void)printf("\tNone\n");
  95.     }
  96.  
  97.     return 0;
  98. }
  99.  
  100.  
  101. void print_info(SLPrinterStruct *ptr)
  102. {
  103.     (void)printf("\n");
  104.     (void)printf("\tName:\t\t%s\n", ptr->local_name);
  105.     (void)printf("\tFormal Name:\t%s\n", ptr->formal_name);
  106.     (void)printf("\tType:\t\t%s\n", ptr->type);
  107.     (void)printf("\tDefault:\t%s\n", (ptr->is_def) ? "Yes": "No");
  108.     (void)printf("\tClass:\t\t%s\n", (ptr->is_class) ? "Yes": "No");
  109.     if (ptr->is_networked) {
  110.     (void)printf("\tRemote host:\t%s\n", ptr->remote_host);
  111.     (void)printf("\tRemote name:\t%s\n", ptr->remote_name);
  112.     } else {
  113.     (void)printf("\tDevice:\t\t%s\n", ptr->dev);
  114.     }
  115. }
  116.